function AccountManager(app, div) {

	var self = this;
	this.bookId = null;
	this.view = null;
	this.accounts = new Array();

	$.extend(this, new Cache());

	$.subscribe('accounts-request', function(event, caller) {
		caller.updateFn(self.accounts);
	});

	this.loadAccounts = function(bookId, dateTo, approvedOnly) {
		if(bookId !== undefined) {
			this.bookId = bookId;
		}
		dateTo = unUndefy(dateTo, null);
		approvedOnly = unUndefy(approvedOnly, true);
		if(this.view == null) {
			this.view = new AccountsView(this, {
				curManager: app.currencyManager,
				dateFilterDiv: 'accountsDateFilter',
				approvedFilterDiv: 'accountsApprovedFilter',
				refreshBtnDiv: 'accountsRefreshBtn',
				createBtnDiv: 'accountCreateBtn',
				tableDiv: 'accountsTable',
				editDialogDiv: 'accountsEditDialog'
			}).init();
			$.subscribe('accounts-loaded', function(event, data) {
				self.view.updateAccounts(data.items);
			});
		}

		app.showProgress('Загрузка счетов ...');
		$.ajax({
			url: 'service/account/read.txt',
			data: { bookId: this.bookId, dateTo: dateTo, approvedOnly: approvedOnly },
			async: true,
			cache: false,
			success: function (data, status, xhr) {
				self.accounts.length = 0;
				self.cleanCache();
				var response = $.parseJSON(data);
				var acc;
				$.each(response.items, function(index, account) {
					acc = new Account().fromJson(account);
					self.accounts.push(acc);
					self.cache(acc);
				});
				$.publish('accounts-loaded', { items: self.accounts });
				app.showNotification('Счета загружены', 1000);
			},
			error: function () {
				app.showWarning('Не удалось загрузить счета книги', 5000);
			}
		});
	};

	this.removeAccount = function(accountId) {
//		console.log('remove account' + accountId);
	};
};